### A Vector Embedding Index Search Guide

This guide will show how run a search against a vector embedding index.

### Create an index

Create a vector embedding index if it does not already exist. In this example we will create an index for the sentence embedding stored in the `model2vec_embeddings` field.

`model2vec_embeddings`

    // embeddings indexes
    CREATE VECTOR INDEX pubmed_document_model2vec_embeddings_index IF NOT EXISTS
        FOR (n:pubmed_document)
        ON n.model2vec_embeddings
        OPTIONS { indexConfig: {
            `vector.dimensions`: 256,
            `vector.similarity_function`: 'cosine'
        }
    };

    CREATE VECTOR INDEX drug_model2vec_embeddings_index IF NOT EXISTS
        FOR (n:drug)
        ON n.model2vec_embeddings
        OPTIONS { indexConfig: {
            `vector.dimensions`: 256,
            `vector.similarity_function`: 'cosine'
        }
    };

    CREATE VECTOR INDEX disease_model2vec_embeddings_index IF NOT EXISTS
        FOR (n:disease)
        ON n.model2vec_embeddings
        OPTIONS { indexConfig: {
            `vector.dimensions`: 256,
            `vector.similarity_function`: 'cosine'
        }
    };

    CREATE VECTOR INDEX gene_protein_model2vec_embeddings_index IF NOT EXISTS
        FOR (n:gene_protein)
        ON n.model2vec_embeddings
        OPTIONS { indexConfig: {
            `vector.dimensions`: 256,
            `vector.similarity_function`: 'cosine'
        }
    };

    CREATE VECTOR INDEX anatomy_model2vec_embeddings_index IF NOT EXISTS
        FOR (n:anatomy)
        ON n.model2vec_embeddings
        OPTIONS { indexConfig: {
            `vector.dimensions`: 256,
            `vector.similarity_function`: 'cosine'
        }
    };

Create vector index is not exists

### Show vector indexes

Create a vector embedding index if it does not already exist. In this example we will create an index for the sentence embedding stored in the `model2vec_embeddings` field.

Show vector indexes if not exists. Look for `online` status and not `populating`

    SHOW VECTOR INDEXES;

Show Vector Indexes

### Query Similar Embeddings

Query similar embeddings with the `queryNodes` command. The `model2vec_embeddings` is a merged embedding generated from the article `title` and `keywords` fields.

In this example we query for a "graft verse host disease" article.

    MATCH (n:pubmed_document { pmcid: '11759061' })
    CALL db.index.vector.queryNodes('pubmed_document_model2vec_embeddings_index', 25, n.model2vec_embeddings)
    YIELD node AS article, score
    RETURN score, article.pmcid AS pmcid, article.keywords as keywords, article.title AS title;

graft-vs-host-disease